/**
 * UniApp 模拟器检测工具类
 */
export default class EmulatorDetector {
    /**
     * 综合判断是否为模拟器
     * @returns {Promise<boolean>} 是否为模拟器
     */
    static async isEmulator() {
        // 多端检测，取并集
        const checks = [
            this.checkSystemInfo(),
        
        ];
        
        // 只要有一项检测为模拟器，就返回true
        const results = await Promise.all(checks);
        return results.some(result => result);
    }
    
    /**
     * 通过系统信息检测
     */
    static async checkSystemInfo() {
        try {
            const systemInfo = uni.getSystemInfoSync();
            console.log(systemInfo);
            // 提取设备信息
            const { model, brand, manufacturer, platform } = systemInfo;
            const modelLower = model
			console.log("model",modelLower);
            const brandLower = (brand || '').toLowerCase();
            const manufacturerLower = (manufacturer || '').toLowerCase();
            console.log(systemInfo);
            // 常见模拟器特征关键词
            const emulatorKeywords = [
                'emulator', 'simulator', 'virtual', 'genymotion',
                'nox', '雷电', 'mumu', 'ldplayer', 'android sdk',
                'google sdk', 'qemu', 'vmware', 'virtualbox','BRA-AL00'
            ];
            
            // 检查设备型号、品牌是否包含模拟器特征
            const hasKeyword = emulatorKeywords.some(keyword => 
                modelLower.includes(keyword) || 
                brandLower.includes(keyword) || 
                manufacturerLower.includes(keyword)
            );
            console.log(hasKeyword);
            // iOS模拟器特征
            if (platform === 'ios' && modelLower.includes('simulator')) {
                return true;
            }
            
            // Android模拟器常见特征组合
            if (platform === 'android') {
                if (brandLower === 'android' && modelLower.includes('generic')) {
                    return true;
                }
            }
            
            return hasKeyword;
        } catch (e) {
            console.error('系统信息检测失败:', e);
            return false;
        }
    }
    

    

}
